<?php

namespace mbilling\BillingBundle\Model;

use Doctrine\ORM\EntityManager;
use mbilling\BillingBundle\Entity\domainsZones;


Class DomainsZonesModel
{
    protected $em;

    public function __construct(EntityManager $em)
    {
        $this->em = $em;
    }

    public function findAll()
    {
        $zones = $this->em->getRepository('BillingBundle:domainsZones')->findAll();
        return $zones;
    }

    public function findByAllActive()
    {
        $zones = $this->em->getRepository('BillingBundle:domainsZones')->findBy(array('is_active' => '1'));
        return $zones;
    }
    
    public function findByPK($zone_id)
    {
        $zone = $this->em->find('BillingBundle:domainsZones', $zone_id);
        return $zone;
    }

    public function findByName($name)
    {
        $zone = $this->em->getRepository('BillingBundle:domainsZones')->findOneBy(array('name' => $name));
        return $zone;
    }
    
    public function create($oEntity)
    {    
        $this->em->persist($oEntity);
        $this->em->flush();
    }
    
    public function removeByPK($zone_id)
    {
        $zone = $this->em->find('BillingBundle:domainsZones', $zone_id);
        $this->em->remove($zone);
        $this->em->flush();
    } 
}
?>
